<?php
include 'connect.php';

//接收修改好的数据并创建x个变量来接收每条数据，并且清空左右的空格
$id=(int)$_POST['id'];
$title=trim($_POST['title']);
$price=trim($_POST['price']);
$jiegou=trim($_POST['jiegou']);
$mianji=trim($_POST['mianji']);
$louceng=trim($_POST['louceng']);
$address=trim($_POST['address']);
$fdname=trim($_POST['fdname']);
$img=trim($_POST['img']);

//修改用户点击到的db id 里的数据库每个字段的数据
$result=mysqli_query($link,"update house set id = '$id', title = '$title', price = '$price', jiegou = '$jiegou', 
mianji = '$mianji', louceng = '$louceng', address = '$address' , fdname = '$fdname', img = '$img' where id = '$id'");

//如果db语句生效则删除成功0.5秒后返回，反之亦然
if ($result){
    echo '
    <script src="layui-v2.6.8/layui/layui.js"></script>
    <link rel="stylesheet" href="layui-v2.6.8/layui/css/layui.css">
    <div style="margin: 40px auto;width: 500px;height: 100px">
        <i class="layui-icon layui-icon-face-smile-fine" style="font-size: 30px; color: #1E9FFF;"></i>
        <span style="display: inline-block;font-size: 24px;color: #1E9fff">修改成功,正在返回</span>
    </div>
          ';
    header('refresh:0.5;url=page.php');
}else{
    echo '
    <script src="layui-v2.6.8/layui/layui.js"></script>
    <link rel="stylesheet" href="layui-v2.6.8/layui/css/layui.css">
    <div style="margin: 40px auto;width: 500px;height: 100px">
        <i class="layui-icon layui-icon-face-surprised" style="font-size: 30px; color: #1E9FFF;"></i>
        <span style="display: inline-block;font-size: 24px;color: #1E9fff">修改失败,正在返回</span>
    </div>
          ';
    header('refresh:0.5;url=page.php');
}